#pragma once

#include <thread>
#include <string>
#include <memory>
#include <chrono>
#include <mutex>
#include <future>
#include <unistd.h>
#include <condition_variable>
#include "AbstractNode.h"
#include "base/Define.h"
#include "base/Bytes.h"

namespace zeroplus::mq
{
    class ClientNode : public AbstractNode
    {
    public:
        ClientNode(const std::string &uri)
        {
            CreateConnection(zmqpp::socket_type::xreq, uri, ConnectType::connect);
            conn_->SetRecvTimeout(20000);
        }

        ~ClientNode()
        {
        }

        std::tuple<Bytes, bool> InvokeSync(const Bytes &message);

        std::tuple<Bytes, bool> InvokeAsync(const Bytes &message);

        void InvokeOneWay(const Bytes &message);

    private:
        bool SendRequest(const Bytes &message);

        std::tuple<Bytes, bool> RecvResponse();
    };
}
